﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO.Ports;

namespace MIBETerminal
{
    public class SerialPortParameters
    {
        public string PortName { get; set; }
        public int _baudRate;
        public int _dataBits;
        public Parity _parity;
        public StopBits _stopBits;
        public Handshake _handshake;

        public SerialPortParameters()
        {
            PortName = "COM4";
            _baudRate = 15200;
            _dataBits = 8;
            _parity = System.IO.Ports.Parity.None;
            _stopBits = System.IO.Ports.StopBits.One;
            _handshake = System.IO.Ports.Handshake.None;
        }

        public void Parity(String parity)
        {
            _parity = (Parity)Enum.Parse(typeof(Parity), parity);
        }

        public Parity Parity()
        {
                return _parity;
        }

        public void BaudRate(string baudRateString)
        {
            _baudRate = int.Parse(baudRateString);
        }

        public int BaudRate()
        {
            return _baudRate;
        }


        public void DataBits(string dataBits)
        {
            _dataBits =  int.Parse(dataBits);
        }

        public int DataBits()
        {
            return _dataBits;
        }

        public void StopBits(string stopBits)
        {
            _stopBits = (StopBits)Enum.Parse(typeof(StopBits), stopBits);
        }

        public StopBits StopBits()
        {
            return _stopBits;
        }

        public void Handshake(string handshake)
        {
            _handshake = (Handshake)Enum.Parse(typeof(Handshake), handshake);
        }

        public Handshake Handshake()
        {
            return _handshake;
        }
    }
}
